﻿// <copyright file="EmgaatsEditorExtension.cs" company="City of Portland, BES-ASM">
// </copyright>
// <summary>EmgaatsEditorExtension class</summary>

namespace BESASM.EMGAATS.UI.ArcMap
{
  using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Text;
  using ESRI.ArcGIS.Editor;

  /// <summary>
  /// EmgaatsEditorExtension class implementing custom ESRI Editor Extension functionalities.
  /// </summary>
  public class EmgaatsEditorExtension : ESRI.ArcGIS.Desktop.AddIns.Extension
  {
    /// <summary>
    /// Initializes a new instance of the <see cref="EmgaatsEditorExtension"/> class.
    /// </summary>
    public EmgaatsEditorExtension()
    {
    }

    #region Shortcut properties to the various editor event interfaces
    private IEditEvents_Event Events
    {
      get { return ArcMap.Editor as IEditEvents_Event; }
    }

    private IEditEvents2_Event Events2
    {
      get { return ArcMap.Editor as IEditEvents2_Event; }
    }

    private IEditEvents3_Event Events3
    {
      get { return ArcMap.Editor as IEditEvents3_Event; }
    }

    private IEditEvents4_Event Events4
    {
      get { return ArcMap.Editor as IEditEvents4_Event; }
    }
    #endregion

    /// <summary>
    /// Called on startup of Editor Extensions by ArcMap
    /// </summary>
    protected override void OnStartup()
    {
      IEditor theEditor = ArcMap.Editor;
    }

    /// <summary>
    /// Called on shutdown of Editor Extensions by ArcMap
    /// </summary>
    protected override void OnShutdown()
    {
    }

    #region Editor Events

    private void WireEditorEvents()
    {
      // TODO: Sample code demonstrating editor event wiring
      this.Events.OnCurrentTaskChanged += delegate
      {
        if (ArcMap.Editor.CurrentTask != null)
        {
          System.Diagnostics.Debug.WriteLine(ArcMap.Editor.CurrentTask.Name);
        }
      };
      this.Events2.BeforeStopEditing += this.OnBeforeStopEditing;
    }

    private void OnBeforeStopEditing(bool save)
    {
    }
    #endregion
  }
}
